/*
 * Copyright (C) 2010-2011 Graz University of Technology, Austria. All Rights reserved. 
 *
 * Contact: Simone Kopeinik <simone.kopeinik@tugraz.at>
 * 	   Graz University of Technology, Knowledge Management Institute, Brückenkopfgasse 1/6, 8020 Graz 	
 * 	   <http://www.kmi.tugraz.at/>
 * 
 * This software is part of the TARGET platform developed by the
 * TARGET EC-funded project www.reachyourtarget.org
 *
 * This software is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * The GNU General Public License is available at <http://www.gnu.org/licenses/>.
 *
 */
package at.tugraz.kmi.css.analyzer.gapvis.basic;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

import at.tugraz.kmi.css.analyzer.model.CompetenceAnalyzerModel;

import com.google.inject.Inject;

/**
 * The panel containing the visualisation of the gap competence.
 * 
 * 
 * @author Georg Öttl <georg.oettl@gmail.com>
 * 
 */
public class GapProfilePanel extends javax.swing.JPanel {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	public static void main(String[] args) {
		GapProfilePanel viewer = new GapProfilePanel();
		JFrame frame = new JFrame();
		frame.setSize(640, 480);
		frame.getContentPane().add(viewer);
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	private CompetenceAnalyzerModel	model;
	private GapProfileVis			gapVisPanel;

	/** Creates new form GapProfileJPanel */
	GapProfilePanel() {
		initComponents();
	}

	/** Creates new form GapProfileJPanel */
	@Inject
	GapProfilePanel(GapProfileVis visPanel, CompetenceAnalyzerModel presMmodel) {
		model = presMmodel;
		initComponents();
		gapVisPanel = visPanel;
		jPanelVis.add(gapVisPanel);
		jButtonCalcGap.setAction(presMmodel.getUpdateGapAction());
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// <editor-fold defaultstate="collapsed"
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jPanelVis = new javax.swing.JPanel();
		jToolBar1 = new javax.swing.JToolBar();
		jButtonCalcGap = new javax.swing.JButton();

		jPanelVis.setLayout(new java.awt.BorderLayout());

		jToolBar1.setRollover(true);
		jToolBar1.setPreferredSize(new java.awt.Dimension(13, 30));

		jButtonCalcGap.setText("jButton1");
		jButtonCalcGap.setFocusable(false);
		jButtonCalcGap
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButtonCalcGap
				.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButtonCalcGap.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButtonCalcGapActionPerformed(evt);
			}
		});
		jToolBar1.add(jButtonCalcGap);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE,
						400, Short.MAX_VALUE)
				.addComponent(jPanelVis, javax.swing.GroupLayout.DEFAULT_SIZE,
						400, Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup()
						.addComponent(jToolBar1,
								javax.swing.GroupLayout.PREFERRED_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addComponent(jPanelVis,
								javax.swing.GroupLayout.DEFAULT_SIZE, 270,
								Short.MAX_VALUE)));
	}// </editor-fold>//GEN-END:initComponents

	private void jButtonCalcGapActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonCalcGapActionPerformed
		model.getBean().updateGapGraph();
	}// GEN-LAST:event_jButtonCalcGapActionPerformed

	private void jToggleButtonCalcActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jToggleButtonCalcActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jToggleButtonCalcActionPerformed

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton		jButtonCalcGap;
	private javax.swing.JPanel		jPanelVis;
	private javax.swing.JToolBar	jToolBar1;
	// End of variables declaration//GEN-END:variables

}
